const router = require('koa-router')()
const path = require('path')
const { exec } = require('../db/index')
// koa-body
router.post('/api/upload', async (ctx, next) => {
	console.log('----------api/upload-----------')
	// 接收参数
	const file = ctx.request.files.file
	console.log(file, 'file')
	// 处理 路径
	const filePath = ctx.origin + '/uploads/' + path.basename(file.path)
	// 返回路径
	ctx.body = {
		code: 0,
		msg: 'success',
		data: {
			imgurl: filePath
		}
	}
})

module.exports = router
